<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>element对象</title>
</head>
<body>
<a>点我试一试</a>
<input id="btn_set" type="button" value="设置a属性">
<input id="btn_set2" type="button" value="移除a属性">
<script>

    var b = document.getElementById("btn_set")
    b.onclick=function () {
        var element_a = document.getElementsByTagName("a")[0]

        element_a.setAttribute("href","https://www.baidu.com")

    }
    var c = document.getElementById("btn_set2")
    c.onclick=function () {
        var element_a = document.getElementsByTagName("a")[0]

        element_a.removeAttribute("href")

    }
</script>
</body>
</html>